<?php
	include_once("bin/connexion.php");

	if(isset($_POST["connexion"]))
	{
		$mail = $_POST["mail"];
		$password = $_POST["password"];
		$query = "SELECT * FROM user WHERE mail='".$mail."' AND password ='".$password."'";
		$result = mysqli_query($bdd,$query);
		
		if(mysqli_num_rows($result) == 1)
		{
			$user = mysqli_fetch_array($result);
			$_SESSION["user_id"] = $user["id"];
			header("location: index.php");
		}
		else
		{
			header("location: freebed-login.php");
		}
	}
	
	include("freebed-login.html");
?>